#!/bin/bash

qc=lova-qc
test=lova-test
pre=tls-pre
prod=tls-prod
qcenv=config-DQ
testenv=config-DQ
preenv=config-y3pre
prodenv=config-vspprod

for service in `cat /root/script/svc.txt|grep -v ^#`
do
   qcimagename=`kubectl get deployments $service -n $qc -o json --kubeconfig=/root/.kube/$qcenv|jq -r '.spec.template.spec.containers[].image'|awk -F/ '{print $NF}'|awk -F: '{print ($1)}'`
   qcver=`kubectl get deployments $service -n $qc -o json --kubeconfig=/root/.kube/$qcenv|jq -r '.spec.template.spec.containers[].image'|awk -F: '{print $NF}'`
   prodimagename=`kubectl get deployments $service -n $prod -o json --kubeconfig=/root/.kube/$prodenv|jq -r '.spec.template.spec.containers[].image'|awk -F/ '{print $NF}'|awk -F: '{print ($1)}'`
   prodver=`kubectl get deployments $service -n $prod -o json --kubeconfig=/root/.kube/$prodenv|jq -r '.spec.template.spec.containers[].image'|awk -F: '{print $NF}'`
   if [[ ${qcimagename}:${qcver} == ${prodimagename}:${prodver} ]];then
      #echo "${qcimagename}:${qcver} equal ${prodimagename}:${prodver}"
      sleep 0.1
   else
      echo "${qcimagename}:${qcver} not equal ${prodimagename}:${prodver}"
   fi
done
